<?php
namespace bee;

class params extends DAO
{	public $name;
	public $value;
	public $type;
	public $description;


  function SELECT($name = '')
  { if(!$name)
    { $id = $this->name;
    }
    $db = db::getInstance();

    $sqt = "SELECT * FROM " . $db->__NAME_OPEN .  $this->__table . $db->__NAME_CLOSE .
           " WHERE " . $db->__NAME_OPEN . "name" . $db->__NAME_CLOSE . " = :name";
    $stmt = $this->__conn->prepare($sqt);
    $stmt->bindParam(':name', $name, \PDO::PARAM_STR);
    $stmt->setFetchMode(\PDO::FETCH_INTO, $this);
    if($stmt->execute())
    { if($red = $stmt->fetch(\PDO::FETCH_INTO ))
      { return 1;
      }
    }
    return 0;
  }
  function UPDATE()
  { $db = db::getInstance();

    $sqt = "UPDATE " . $db->__NAME_OPEN . $this->__table . $db->__NAME_CLOSE .
      " SET " . $db->__NAME_OPEN . "value" . $db->__NAME_CLOSE . " = :value
        WHERE " .  $db->__NAME_OPEN . "name" . $db->__NAME_CLOSE . " = :name";
    $stmt = $this->__conn->prepare($sqt);
    $stmt->bindParam(':name', $this->name, \PDO::PARAM_STR);
    $stmt->bindParam(':value', $this->value, \PDO::PARAM_STR);
    if($stmt->execute())
    { return 1;
    }
    return 0;

  }

}
function getParam($name)
{	$param = new params();
	$param->SELECT($name);
	return $param->value;
}
